import Vue from 'vue'
import VueRouter from 'vue-router'
import recommend from '../views/recommend.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: "/",
    redirect: "/recommend"
  },
  {
    path:"/userInfo",
    name:"usertInfo",
    component:()=>import("../views/uertInfo.vue"),
    beforeEnter:(to,form,next)=>{
      let login = window.localStorage.getItem("token");
      // 判断没有值
      if(!login){
        next("/login");
        return;
      }else{
        next();
      }
    }
  },
  // {
  //   path:"/recent",  //最近播放路由
  //   name:"recent",
  //   component:() => import("../views/recent.vue")

  // },
  //登录界面
  {
    path:"/login",
    name:"login",
    component:()=>import("../components/base/login.vue")
  },
  //推荐页面
  {
    path: "/recommend",
    name: "recommend",
    component: recommend
  },
  //歌手
  {
    path: "/singer",
    name: "singer",
    component: () => import("../views/singer.vue")
  },
  //排行榜
  {
    path: "/rank",
    name: "rank",
    component: () => import("../views/rank.vue")
  },
  {
    path: "/rank/ranklist",
    name: "ranklist",
    component: () => import("../components/rank/ranklist.vue")
  },
  {
    //歌单详情里面
    path: "/recommend/recommendlist",
    name: "recommendlist",
    component: () => import("../components/recommend/recommendlist.vue")
  },
  //推荐视频
  {
    path:"/recommend/videolist",
    name:"videolist",
    component:()=>import("../components/recommend/videolist.vue")
  },
  //视频
  {
    path:"/recommend/videoMv",
    name:"videoMv",
    component:()=>import("../components/recommend/videoMv.vue")
  },
  
  {
    //搜索
    path:"/search",
    name:"search",
    component:() => import("../views/search.vue")
  },
  //喜欢的音乐
  {
    path:"/base/likeMusic",
    name:"likeMusic",
    component:()=>import("../components/base/likeMusic.vue")
  },
  //我的收藏
  {
    path:"/base/collect",
    name:"collect",
    component:()=>import("../components/base/collect.vue")
  },
  //最近播放
  {
    path:"/base/recentPlay",
    name:"recentPlay",
    component:()=>import("../components/base/recentPlay.vue")
  },
  // {
  //   path:"/base/mv",
  //   name:"mv",
  //   component:()=>import("../components/base/mv.vue")

  // }

  //歌手详情页面
  {
    path:"/singer/singerlist",
    name:"singerlist",
    component:()=>import("../components/singer/singerlist.vue")
  },
  //专辑页面
  {
    path:"/singer/Album",
    name:"Album",
    component:()=>import("../components/singer/Album.vue")
  },
  //视频页面
  {
    path:"/singer/video",
    name:"video",
    component:()=>import("../components/singer/video.vue")
  },
  
 
 
]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
